package ro.cityprojects.adminloc.entities;

import javax.persistence.*;
import java.io.Serializable;

/**
 * BillReportPK class
 *
 * @author bogdan.solga
 * 
 * Date: 13.06.2013, time: 17:47
 */
public class BillReportPK implements Serializable {

    @Id
    @JoinColumn(name = "REPORT_ID", nullable = false, insertable = true, updatable = true)
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private Report report;

    @Id
    @JoinColumn(name = "BILL_ID", nullable = false, insertable = true, updatable = true)
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private Bill bill;

    public Report getReport() {
        return report;
    }

    public void setReport(Report report) {
        this.report = report;
    }

    public Bill getBill() {
        return bill;
    }

    public void setBill(Bill bill) {
        this.bill = bill;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        BillReportPK that = (BillReportPK) o;

        if (bill != null ? !bill.equals(that.bill) : that.bill != null) return false;
        if (report != null ? !report.equals(that.report) : that.report != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = report != null ? report.hashCode() : 0;
        result = 31 * result + (bill != null ? bill.hashCode() : 0);
        return result;
    }
}
